* This file cleans all the data to analyze the list experiments on the 2012 CCAP module. The list experiments deal with African American, gay, Muslim, and Mormon presidential candidates. Current as of Thursday, May 28, 2020. 

clear

* Run from Macintosh Air.
* log using "\\Client\C$\Users\ericschmidt\Dropbox\Base Dropbox\List Experiment Paper (PS)\Conditional Accept\Replication Files (Carmines-Schmidt PS)\2012 CCAP\Dataset Creation\dataset-creation.log", replace
* use "\\Client\C$\Users\ericschmidt\Dropbox\Base Dropbox\List Experiment Paper (PS)\Conditional Accept\Replication Files (Carmines-Schmidt PS)\2012 CCAP\Dataset Creation\CCAP-2012-raw.dta", clear 
set more off 

* Baseline condition: list experiment item counts.  
tab IUB356
gen baseline_le = IUB356
tab baseline_le
recode baseline_le 1=0 2=1 3=2 4=3 5=4
tab baseline_le
tab baseline_le IUB356, m

* "African American candidate" condition: list experiment item counts. 
tab IUB357
gen afroam_le = IUB357
tab afroam_le
recode afroam_le 1=0 2=1 3=2 4=3 5=4 6=5
tab afroam_le
tab afroam_le IUB357, m

* "'Gay or homosexual' candidate" condition: list experiment item counts. 
tab IUB358
gen gays_le = IUB358
tab gays_le
recode gays_le 1=0 2=1 3=2 4=3 5=4 6=5
tab gays_le
tab gays_le IUB358, m

* "Muslim candidate" condition: list experiment item counts. 
tab IUB359
gen muslim_le = IUB359
tab muslim_le
recode muslim_le 1=0 2=1 3=2 4=3 5=4 6=5
tab muslim_le
tab muslim_le IUB359, m

* "Mormon candidate" condition: list experiment item counts. 
tab IUB360
gen mormon_le = IUB360
tab mormon_le 
recode mormon_le 1=0 2=1 3=2 4=3 5=4 6=5
tab mormon_le
tab mormon_le IUB360, m

* Treatment group
gen treatment = "Control" if baseline_le != . 
replace treatment = "African Americans" if afroam_le !=. 
replace treatment = "Gays" if gays_le !=. 
replace treatment = "Muslims" if muslim_le !=. 
replace treatment = "Mormons" if mormon_le !=. 
tab treatment
* Check the different cross-tabs 
tab treatment baseline_le, m
tab treatment afroam_le, m
tab treatment gays_le, m
tab treatment muslim_le, m
tab treatment mormon_le, m

* Item count total, regardless of treatment. 
gen item_count = baseline_le if baseline_le != . 
replace item_count = afroam_le if afroam_le != . 
replace item_count = gays_le if gays_le != . 
replace item_count = muslim_le if muslim_le != .
replace item_count = mormon_le if mormon_le != . 
tab item_count
* Check cross-tabs
tab item_count treatment, m
tab baseline_le
tab afroam_le
tab gays_le 
tab muslim_le 
tab mormon_le
* Check 

* Partisanship (seven-point scale). 
tab pp_pid7 
gen pid_7 = pp_pid7
tab pid_7 
recode pid_7 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=. 
tab pid_7 
tab pp_pid7 pid_7, m
* 0-to-6 scale, where 0 = strong Democrat and 6 = strong Republican. 

* Democrat. Code independents as leaners. 
tab pp_pid7  
gen democrat = pp_pid7 
tab democrat 
recode democrat (1/3 = 1) (4/8 = 0)
tab democrat
tab democrat pp_pid7, m
* Binary variable, 1 = Democrat; 0 = not Democrat. 

* Republican. Code independents as leaners. 
tab pp_pid7 
gen republican = pp_pid7 
tab republican
recode republican (1/4 = 0) (5/7 = 1) (8 = 0) 
tab republican
tab republican pp_pid7, m
* Binary variable, 1 = Republican; 0 = not Republican.  

* Ideology (5-point scale).
tab pp_ideo5
gen ideology = pp_ideo5
tab ideology
recode ideology 1=0 2=1 3=2 4=3 5=4 6=. 
tab ideology
tab ideology pp_ideo5, m
* 0-to-4 scale where 0 = very liberal and 4 = very conservative. 

* Liberal. 
tab pp_ideo5
gen liberal = pp_ideo5
tab liberal
recode liberal (1/2 = 1) (3/6 = 0)
tab liberal 
tab liberal pp_ideo5, m
* Binary variable, 1 = liberal; 0 = not liberal. 

* Conservative.  
tab pp_ideo5
gen conservative = pp_ideo5
tab conservative
recode conservative (1/3 = 0) (4/5 = 1) (6 = 0)
tab conservative
tab conservative pp_ideo5, m
* Binary variable, 1 = conservative; 0 = not conservative. 

* Gender 
tab pp_gender
gen female = pp_gender
tab female
recode female 2=1 1=0
tab female
tab female pp_gender, m
* Binary variable, 1 = female; 0 = male 

* Black 
tab pp_race
gen black = pp_race
tab black 
recode black (1=0) (2=1) (3/8 = 0) 
tab black
tab black pp_race, m
* Binary variable, 1 = black; 0 = not black 

* White
tab pp_race
gen white = pp_race
tab white
recode white (1 = 1) (2/8 = 0) 
tab white
tab white pp_race, m
* Binary variable, 1 = white, 0 = not white  

* Education (6-point scale) 
tab pp_educ
gen education = pp_educ
tab education
recode education 1=0 2=1 3=2 4=3 5=4 6=5 
tab education 
tab education pp_educ, m
* 0-to-5 scale, 0 = no HS; 1 = high school graduate; 2 = some college; 3 = 2-year college; 4 = college graduate; 5 = post-graduate 

* Church attendance
tab pp_pew_churatd
gen church = pp_pew_churatd
tab church
recode church 1=5 2=4 3=3 4=2 5=1 6=0 7=.
tab church 
tab church pp_pew_churatd, m
* 0-to-5 scale, 0 = never; 5 = more than once per week. 'Don't know' responses are dropped. 

* Racial resentment, question 1. 
* "Generations of slavery and discrimination have created conditions that make it difficult for Blacks to work their way out of the lower class." Strongly  agree is the LEAST racially resentful response; strongly disagree is the MOST racially resentful response. 
tab pp_raceresent_4
gen rr_1 = pp_raceresent_4
tab rr_1
recode rr_1 1=-2 2=-1 3=0 4=1 5=2
tab rr_1 
tab rr_1 pp_raceresent_4, m
* -2-to-2 scale, -2 = strongly agree; 2 = strongly disagree. Here, we are coding "Don't know" at the midpoint. 

* Racial resentment, question 2. 
* "Irish, Italians, Jewish, and many other minorities overcame prejudice and worked their way up. Blacks should do the same without any special favors." Strongly agree is the MOST racially resentful response, and strongly disagree is the LEAST racially resentful response. 
tab pp_raceresent_2
gen rr_2 = pp_raceresent_2
tab rr_2
recode rr_2 1=2 2=1 3=0 4=-1 5=-2
tab rr_2 
tab rr_2 pp_raceresent_2, m
* -2-to-2 scale, -2 = strongly disagree; 2 = strongly agree. Here, we are coding "Don't know" at the midpoint. 

* Racial resentment, question 3. 
* "Over the past few years, blacks have gotten less than they deserve." Strongly agree is the LEAST racially resentful response, and strongly disagree is the MOST racially resentful response.
tab pp_raceresent_1
gen rr_3 = pp_raceresent_1
tab rr_3
recode rr_3 1=-2 2=-1 3=0 4=1 5=2 
tab rr_3 
tab rr_3 pp_raceresent_1, m
* -2-to-2 scale, -2 = strongly agree; 2 = strongly disagree. Here, we are coding "Don't know" at the midpoint. 

* Racial resentment, question 4. 
* "It's really a matter of some people not trying hard enough. If blacks would only try harder, they could be just as well off as whites." Strongly agree is the MOST racially resentful response, and strongly disagree is the LEAST racially resentful response. 
tab pp_raceresent_3
gen rr_4 = pp_raceresent_3
tab rr_4
recode rr_4 1=2 2=1 3=0 4=-1 5=-2 
tab rr_4 
tab rr_4 pp_raceresent_3, m
* -2-to-2 scale, -2 = strongly disagree; 2 = strongly agree. Here, we are coding "Don't know" at the midpoint. 

* Racial resentment index 
gen rr = rr_1 + rr_2 + rr_3 + rr_4 
tab rr
* -8 to 8 scale, where -8 is the lowest level of racial resentment and 8 is the highest level of racial resentment. 

* Respondent position on same-sex marriage. 
tab pp_gaymar2
gen gay_marriage = pp_gaymar2
tab gay_marriage
recode gay_marriage 1=2 2=0 3=1 
tab gay_marriage 
tab pp_gaymar2 gay_marriage, m
* 3-point scale, 0 = oppose; 1 = 'not sure'; 2 = favor same-sex marriage. 

* Importance of religion
tab pp_pew_religimp
gen relig_importance = pp_pew_religimp
tab relig_importance
recode relig_importance 1=3 2=2 3=1 4=0 
tab relig_importance 
tab pp_pew_religimp relig_importance, m
* 0-to-3 scale, 0 = not at all important; 1 = not too important; 2 = somewhat important; 3 = very important

* Mitt Romney favorability 
tab pp_fav_romn
gen romney_favor = pp_fav_romn
tab romney_favor 
recode romney_favor 1=4 2=3 3=1 4=0 8=2
tab romney_favor
tab pp_fav_romn romney_favor, m
* 0-to-4 scale, 0 = very unfavorable; 1 = somewhat unfavorable; 2 = don't know; 3 =  somewhat favorable; 4 = very favorable. 

* Barack Obama favorability
tab pp_fav_obama
gen obama_favor = pp_fav_obama
tab obama_favor
recode obama_favor 1=4 2=3 3=1 4=0 8=2
tab obama_favor
tab pp_fav_obama obama_favor, m
* 0-to-4 scale, 0 = very unfavorable; 1 = somewhat unfavorable; 2 = don't know; 3 =  somewhat favorable; 4 = very favorable. 

* Political interest, measured as level of interest in politics or current affairs. 
tab pp_polinterest
gen interest = pp_polinterest
tab interest
recode interest 1=2 2=1 3=0 4=. 
tab interest
tab pp_polinterest interest, m
* 0 = not that much; 1 = somewhat interested; 2 = very interested. 'Not sures' are dropped. 

* Family income 
tab pp_faminc
gen income = pp_faminc
tab income
recode income (31 97 = .) 
tab income
replace income = income - 1 
tab income
tab income pp_faminc, m
* Income is a 0-to-15 scale, where 0 = less than $10,000, and 15 = $500,000 or more. Dropped the people that "preferred not to say" as well as those classified as "$150,000 or more" rather than "$150,000-$199,999" 

* Dummy variable: "African American candidate" condition. 
gen afroam_treatment = 0 
replace afroam_treatment = 1 if afroam_le != . 
tab afroam_treatment
tab afroam_treatment treatment, m 
tab afroam_treatment item_count, m
tab afroam_le
* Binary indicator of treatment condition. 1 = assigned to "African American candidate" condition; 0 = assigned to other conditions. 

* Dummy variable: baseline condition. 
gen baseline_treatment = 0 
replace baseline_treatment = 1 if baseline_le != . 
tab baseline_treatment
tab baseline_treatment treatment, m 
tab baseline_treatment item_count, m
tab baseline_le
* Binary indicator of treatment condition. 1 = assigned to baseline condition; 0 = assigned to other conditions. 

* Dummy variable: "'Gay or homosexual' candidate" condition. 
gen gay_treatment = 0 
replace gay_treatment = 1 if gays_le != . 
tab gay_treatment
tab gay_treatment treatment, m 
tab gay_treatment item_count, m
tab gays_le
* Binary indicator of treatment condition. 1 = assigned to "'Gay or homosexual' candidate" condition; 0 = assigned to other conditions. 

* Dummy variable: "Muslim candidate" condition. 
gen muslim_treatment = 0 
replace muslim_treatment = 1 if muslim_le != . 
tab muslim_treatment
tab muslim_treatment treatment, m 
tab muslim_treatment item_count, m
tab muslim_le
* Binary indicator of treatment condition. 1 = assigned to "Muslim candidate" condition; 0 = assigned to other conditions. 

* Dummy variable: "Mormon candidate" condition. 
gen mormon_treatment = 0 
replace mormon_treatment = 1 if mormon_le != . 
tab mormon_treatment
tab mormon_treatment treatment, m 
tab mormon_treatment item_count, m
tab mormon_le
* Binary indicator of treatment condition. 1 = assigned to "Mormon candidate" condition; 0 = assigned to other conditions. 

* "African American candidate" or baseline condition 
gen afroam_binary = . 
replace afroam_binary = 0 if baseline_treatment==1 
replace afroam_binary = 1 if afroam_treatment==1
tab afroam_binary
tab afroam_binary treatment, m
* Binary variable, 1 = "African American candidate" condition; 0 = baseline condition. 

* "'Gay or homosexual' candidate" or baseline condition
gen gays_binary = . 
replace gays_binary = 0 if baseline_treatment==1 
replace gays_binary = 1 if gay_treatment==1
tab gays_binary
tab gays_binary treatment, m
* Binary variable, 1 = "'Gay or homosexual' candidate" condition; 0 = baseline condition. 

* "Muslim candidate" or baseline condition 
gen muslim_binary = . 
replace muslim_binary = 0 if baseline_treatment==1 
replace muslim_binary = 1 if muslim_treatment==1
tab muslim_binary
tab muslim_binary treatment, m
* Binary variable, 1 = "Muslim candidate" condition; 0 = baseline condition. 

* "Mormon candidate" or baseline condition  
gen mormon_binary = . 
replace mormon_binary = 0 if baseline_treatment==1
replace mormon_binary = 1 if mormon_treatment==1
tab mormon_binary
tab mormon_binary treatment, m
* Binary variable, 1 = "Mormon candidate" condition; 0 = baseline condition. 

* Save to an external file. 
* save "\\Client\C$\Users\ericschmidt\Dropbox\Base Dropbox\List Experiment Paper (PS)\Conditional Accept\Replication Files (Carmines-Schmidt PS)\2012 CCAP\Dataset Creation\CarminesSchmidtPS-replication-2012.dta", replace

exit, clear
